﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;

public partial class News_contactadmin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            gridsload();
            LoadTop10();
        }   
    }
    protected void gridsload()
    {
        StringBuilder Sqlstr1 = new StringBuilder();
        DataTable dt1 = new DataTable();
        Sqlstr1.Append("select collegename,[name],title,field,telephone,cellphone,email from Dict_College left join Sys_Account on collegename=depart and usertype=2");
        dt1 = PM.Code.DAL.DbHelper.ExecuteDataTableBySql(Sqlstr1.ToString());
        GridView1.DataSource = dt1;
        GridView1.DataBind();
        StringBuilder Sqlstr2 = new StringBuilder();
        DataTable dt2 = new DataTable();
        Sqlstr2.Append("select btnname,[name],title,field,telephone,cellphone,email from Sys_Guide left join Sys_Account on inchargeid=Sys_Account.tid and usertype=3 where btnname<>'系统管理'");
        dt2 = PM.Code.DAL.DbHelper.ExecuteDataTableBySql(Sqlstr2.ToString());
        GridView2.DataSource = dt2;
        GridView2.DataBind();
    }
    protected void LoadTop10()
    {
        StringBuilder sb = new StringBuilder();
        StringBuilder strTable = new StringBuilder();
        sb.Append("select top 10 pname from Bus_Project where status='3' order by approvaldate desc");
        SqlDataReader reader = PM.Code.DAL.DbHelper.ExecuteDataReaderBySql(sb.ToString());
        strTable.Append("<ul>");
        while (reader.Read())
        {
            strTable.AppendFormat("<li>{0}</li>", reader[0].ToString());
        }
        strTable.Append("</ul>");
        if (reader.HasRows)
        {
            top10.InnerHtml = strTable.ToString();
        }
        else
        {
            top10.InnerHtml = "无最近立项的项目";
        }
        reader.Close();
    }
}
